package booroo.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class OracleJDBC {
	private static final String DRV="oracle.jdbc.OracleDriver";
	private static final String URL="jdbc:oracle:thin:@//112.216.253.122:1521/xe";
	private static final String USR="booroo83";
	private static final String PWD="booroo83";
	
	
	
	private static final String ZIPCODE="zipcode";
	
	//oracle JDBC 객체 생성
	//new 연산자 없이 openConn 메서드를 호출하기 위해 static 으로 선언
	//우편번호 검색시 사용할 접속정보
	public static Connection openConn(){
		Connection conn=null;
		try{
		Class.forName(DRV);
		conn=DriverManager.getConnection(URL, USR, PWD);
		}catch(Exception ex){
			ex.printStackTrace();
		}
		return conn;
	}
	
	public static Connection openzipcode(){
		Connection conn=null;
		try{
		Class.forName(DRV);
		conn=DriverManager.getConnection(URL, ZIPCODE, ZIPCODE);
		}catch(Exception ex){
			ex.printStackTrace();
		}
		return conn;
	}
	
	//oracle JDBC 객체 종료 및 해제
	public static void closeConn(Connection conn, PreparedStatement ps, ResultSet rs){
		
		if(rs!=null){
			try{rs.close();} catch(Exception ex){}
		}
		if(ps!=null){
			try{ps.close();} catch(Exception ex){}
		}
		if(conn!=null){
			try{conn.close();} catch(Exception ex){}
		}
		
		
		}
	}
